----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  F:/Dropbox (UBC-Umich)/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data_historical/dataverse_files/code/logs/table_01_elasticity.log
  log type:  text
 opened on:  28 Oct 2022, 01:10:46

. 
. *-------------------------------------------------------------------------------

. 
. 
. 
. 
. 
. 
. 
. 
. 
. ************************ TABLE 1  **************************

. 
. local mastervar "_sales"

. 
. local grvar0 "LP_ppp_emp_pwt" 

. 
. global ctryrel FR

. 
. local yy "2016"

. 
. local nn=10 /*minimum number of sectors allowed per year-isocode*/
10/ invalid name
r(198);

. 
. local sample `" isocode=="" "'

. 
. 
. 
. 
. 
. local heading "baseline"  

. 
. if "`heading'"=="baseline" {
. 
. local ending "" 
. 
. local zz naics  
. 
. local var0 "`mastervar'" 
. 
. local name "_base" 
. 
. local name1 "_woparent" 
. 
. local samp=1  
. 
. local title "`zz'`var0'_s`samp'`name'`name1'`ending'"
. 
. display "`title'"
naics_sales_s1_base_woparent
. 
. }

. 
. 
. 
. 
. 
. *Restricting the set of isocode-years for those pairs with less than `nn' sectors

. 
. *----------------------------------------------------------

. 
. clear all

. 
. use "${data}/estimates_sec_`title'.dta", clear

. 
. gsort year type sector -DA

. 
. by year isocode, sort: egen num=count( fe_location )

. 
. table isocode year, c(mean  num)

----------------
          | year
  isocode | 2016
----------+-----
       AT |   17
       BE |   19
       BG |   17
       CZ |   18
       DE |   19
       DK |   18
       EE |   17
       ES |   18
       FI |   18
       FR |   18
       GB |   18
       GR |   17
       HR |   17
       HU |   18
       IT |   18
       JP |   15
       KR |   17
       LT |   17
       LV |   17
       MX |   15
       NL |   18
       PL |   18
       PT |   18
       RO |   19
       SE |   19
       SI |   18
       SK |   18
----------------

. 
. keep if num>=`nn'
invalid syntax
r(198);

. 
. keep year isocode

. 
. duplicates drop 

Duplicates in terms of all variables

(450 observations deleted)

. 
. tempfile iso

. 
. save `iso', replace 
(note: file C:\Users\VANESS~1\AppData\Local\Temp\ST_2d9c_00000d.tmp not found)
file C:\Users\VANESS~1\AppData\Local\Temp\ST_2d9c_00000d.tmp saved

. 
. 
. 
. 
. 
. *Restricting the set of isocode-years for those pairs with less than `nn' sectors

. 
. *----------------------------------------------------------

. 
. use "${data}/estimates_sec_`title'.dta", clear

. 
. keep if year==`yy'
(0 observations deleted)

. 
. drop if sector1==sector
(0 observations deleted)

. 
. tab type

       type |      Freq.     Percent        Cum.
------------+-----------------------------------
      manuf |        162       33.96       33.96
  nonmarket |         75       15.72       49.69
     others |         78       16.35       66.04
       serv |        162       33.96      100.00
------------+-----------------------------------
      Total |        477      100.00

. 
. replace DA=. if num_aff<3
(31 real changes made, 31 to missing)

. 
. replace DP=. if num_aff<3
(0 real changes made)

. 
. levelsof sector, local(seclist)
`"Accomod_Recreat (I-R-S)"' `"AgrMining (A-B)"' `"Basic Metals (24-25)"' `"ChePetPla (19-23)"' `"Construction (F)"' `"Education (P)"' `"ElecMach (26-28)"' `"Electricity (D-E)"' `
> "Financial_Insurance (K)"' `"Food (10-12)"' `"Health (Q)"' `"Information (J)"' `"Public_Administration (O)"' `"Real_Estate (L)"' `"Support_Services (M-N)"' `"TexWood (13-18)"' 
> `"TranspOtherManuf (29-33)"' `"Transportation_Storage (H)"' `"Wholesale_Retail (G)"'

. 
. 
. 
. merge m:1 year isocode using `iso'

    Result                           # of obs.
    -----------------------------------------
    not matched                             0
    matched                               477  (_merge==3)
    -----------------------------------------

. 
. keep if _merge==3
(0 observations deleted)

. 
. drop _merge

. 
. capture rename DA D_A

. 
. capture rename DP D_P

. 
. drop if D_A==. | (D_A==0 & isocode!="FR")
(32 observations deleted)

. 
. drop if `sample'  
(0 observations deleted)

. 
. display "`drop if `sample''"


. 
. 
. 
. 
. 
. *Bring some aggregate control variables

. 
. *----------------------------------------------------------

. 
. merge m:1 year isocode sector using "${data}/aggregates_tfp_lp_klems.dta"
(note: variable sector was str26, now str37 to accommodate using data's values)

    Result                           # of obs.
    -----------------------------------------
    not matched                        12,067
        from master                         0  (_merge==1)
        from using                     12,067  (_merge==2)

    matched                               445  (_merge==3)
    -----------------------------------------

. 
. drop if _merge==2
(12,067 observations deleted)

. 
. drop _merge

. 
. gen k_y=ln_ck-ln_rgdpo

. 
. 
. 
. merge m:1 year isocode using "${data}/additional_agg_indicators.dta"

    Result                           # of obs.
    -----------------------------------------
    not matched                         1,290
        from master                         0  (_merge==1)
        from using                      1,290  (_merge==2)

    matched                               445  (_merge==3)
    -----------------------------------------

. 
. drop if _merge==2
(1,290 observations deleted)

. 
. drop _merge

. 
. 
. 
. gen ln_patent=ln(patent_total)

. 
. gen ln_patent_pc=ln_patent-ln_pop

. 
. gen ln_trademark=ln(trademark_application)

. 
. gen ln_trademark_pc=ln_trademark-ln_pop

. 
. gen ln_researcher_permm=ln(Researchers_RD_permm)

. 
. gen ln_mobile_per100=ln(mobile_per100) 

. 
. gen ln_broadband_per100=ln(broadband_per100) 

. 
. gen ln_electric_pc=ln(electric_percapita) 

. 
. gen ln_freshwater_pc=ln(freshwater_percapita) 

. 
. gen ln_air_transp=ln(air_transp) 
(51 missing values generated)

. 
. gen ln_container_port=ln(container_port)
(51 missing values generated)

. 
. gen ln_schooling=ln(schooling)

. 
. egen gov_index=rowmean(PoliticalStability GovernmentEffectiveness RegulatoryQuality RuleofLaw ControlofCorruption)

. 
. egen gov_rank_index=rowmean(PoliticalStability_rank GovernmentEffectiveness_rank RegulatoryQuality_rank RuleofLaw_rank ControlofCorruption_rank)

. 
. 
. 
. levelsof sector, local(secs)
`"Accomod_Recreat (I-R-S)"' `"AgrMining (A-B)"' `"Basic Metals (24-25)"' `"ChePetPla (19-23)"' `"Construction (F)"' `"Education (P)"' `"ElecMach (26-28)"' `"Electricity (D-E)"' `
> "Financial_Insurance (K)"' `"Food (10-12)"' `"Health (Q)"' `"Information (J)"' `"Real_Estate (L)"' `"Support_Services (M-N)"' `"TexWood (13-18)"' `"TranspOtherManuf (29-33)"' `
> "Transportation_Storage (H)"' `"Wholesale_Retail (G)"'

. 
. tempfile temp

. 
. save `temp', replace 
(note: file C:\Users\VANESS~1\AppData\Local\Temp\ST_2d9c_00000e.tmp not found)
file C:\Users\VANESS~1\AppData\Local\Temp\ST_2d9c_00000e.tmp saved

. log close
      name:  <unnamed>
       log:  F:/Dropbox (UBC-Umich)/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data_historical/dataverse_files/code/logs/table_01_elasticity.log
  log type:  text
 closed on:  28 Oct 2022, 01:10:58
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
